﻿import mx.utils.Delegate;

import com.mixmedia.mx.AbstractMovieClipEventDispatcher;
import com.mixmedia.mx.events.EventButton;
import com.mixmedia.mx.IEventDispatcher;
/**
 * @author Colin
 */
class com.fangmeiti.control.ToggleButton extends AbstractMovieClipEventDispatcher implements IEventDispatcher{
	private var _isEnable:Boolean = false;
	private var mcOnIcon:MovieClip;
	private var mcOffIcon:MovieClip;
	private var hitArea:Button;

	private function ToggleButton(){
		mcOnIcon._visible = true;
		mcOffIcon._visible = false;
		hitArea.onRelease = Delegate.create(this,release);
	}

	private function release(){
		isEnable = !isEnable;
		dispatchEvent(new EventButton(this,EventButton.EVENTRELEASE));
	}
	
	public function set isEnable(bln:Boolean):Void{
		_isEnable = bln;
		mcOnIcon._visible = !isEnable;
		mcOffIcon._visible = isEnable;
	}

	public function get isEnable():Boolean{
		return _isEnable;
	}
}